import re
import requests

url = "http://www.hao123.com/"

ua = {"user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"}

rq = requests.get(url, headers=ua)

title_pattern = r"(?<=<title>).*?(?=</title>)"

title_search = re.search(title_pattern, rq.text)

title = title_search.group()
print("网站的标题是：", title)